<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/jquery-1.10.1.min.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        li {
            list-style: none;
        }

        img {
            vertical-align: top;
            border: 0;
        }

        .wrap {
            width: 400px;
            height: 400px;
            border: 1px solid #000;
            margin: 100px auto;
            position: relative;
            overflow: hidden;
        }

        .wrap .swiper {
            width: 2000px;
            overflow: hidden;
            position: absolute;
            left: 0;
        }

        .wrap .swiper li {
            float: left;
            width: 400px;
            height: 400px;
        }

        .wrap .swiper li img {
            width: 100%;
        }

        .menu {
            position: absolute;
            right: 10px;
            bottom: 10px;
        }

        .menu li {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: #fff;
            margin: 0 10px;
            float: left;
        }

        .menu li.active {
            background-color: pink;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <ul class="swiper">
            <li><img src="images/girlbig1.jpg" alt=""></li>
            <li><img src="images/girlbig2.jpg" alt=""></li>
            <li><img src="images/girlbig3.jpg" alt=""></li>
            <li><img src="images/girlbig4.jpg" alt=""></li>
            <li><img src="images/girlbig1.jpg" alt=""></li>
        </ul>
        <div class="menu">
            <li class="active"></li>
            <li></li>
            <li></li>
            <li></li>
        </div>
    </div>
</body>
<script>
    $(function () {

        var index = 0;
        var timer = null;

        move();

        function move() {
            clearInterval(timer);
            timer = setInterval(function () {
                index++;
                console.log(index);
                $(".swiper").animate({ left: -400 * index }, 500, function () {
                    if (index >= 4) {
                        index = 0;
                        $(".swiper").css({ left: 0 });

                    }
                    $(".menu li").eq(index).addClass("active").siblings().removeClass("active");
                })
            }, 2000);
        }

        $(".wrap").hover(function () {
            clearInterval(timer);
        }, function () {
            move();
        })

        $(".menu li").click(function () {
            index = $(this).index();
            $(".swiper").animate({ left: -400 * index });
            $(".menu li").eq(index).addClass("active").siblings().removeClass("active");
        })


    })

</script>

</html>